<?php

namespace App\Http\Controllers\Auth;


use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;

class CollectController extends Controller
{

    public function postCollect(Request $request)
    {
        $operate = $request->input('operate');
        $fileId = $request->input('file_id');

        $user = Auth::user();

        if ($operate == 'star')
            $user->collects()->attach($fileId);

        if ($operate == 'unstar')
            $user->collects()->detach($fileId);

        return Response::json([
            'status' => 'success',
            'msg' => ''
        ]);
    }
}